package demo.IOInputOutput;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @Auther: hjy(lc))
 * @Date: 2022/8/15-08-15-11:09
 * @Description：demo.IOInputOutput
 */
public class Code_2 {
    public static void main(String[] args) {
        //解码和编码方式不一致
        BufferedReader br = null;
        try {
            //确保编码方式和解码方式
            //将字节流转为字符流，并指定编码
            InputStreamReader isr = new InputStreamReader(new FileInputStream("a.txt"),"utf-8");
            br = new BufferedReader(isr);
            //br = new BufferedReader(new FileReader("a.txt"));
            String line = null;
            while((line = br.readLine())!= null){
                System.out.println(line);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                if(br != null){
                    br.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
